<template>
    <Form style="line-height:32px" ref="formdata" :model="formdata" :label-width="120" inline>
        <FormItem label="扣款金额" style="width:90%" :rules="required" prop="amount">
            <Input v-model="formdata.amount"/>
        </FormItem>
        <FormItem label="处理原因" style="width:90%" :rules="required" prop="cause">
            <Input v-model="formdata.cause" :rows="3" type="textarea"/>
        </FormItem>
        <footer class="text-right">
             <Button type="primary" @click="submit">提交</Button>
             <Button class="margin-left-10" @click="cancel">取消</Button>
        </footer>
        <Spin size="large" fix v-if="loading"></Spin>
    </Form>
</template>
<script>
import { HttpBatchRefreeze } from "@/service/api/views";
export default {
    props: ['activeids'],
    data(){
        return {
            loading: false,
            formdata:{  
                amount:"",
                cause:'',
            },
            required: [{
                required: true,
                message: '该信息不能为空,请填写'
            }],    
        }
    },
    methods:{
        cancel() {
            this.$emit('on-close')
        },
        async submit(){
            let bool = await this.$refs['formdata'].validate();
			if (!bool) return;
            this.loading = true;
            HttpBatchRefreeze({
                ids:this.activeids,
                amount:this.formdata.amount,
                cause:this.formdata.cause
            }).then(res => {
                this.$Message.success(res.message);
                this.cancel();
                this.$emit('on-update');
            },err => {
                this.$Message.error(err.message);
            }).finally(() => {
                this.loading = false;
            })
        },
    }
}
</script>
